package com.lijiaxing.service.impl;

import com.lijiaxing.mapper.updateMapper;
import com.lijiaxing.mapper.userMapper;
import com.lijiaxing.pojo.Result;
import com.lijiaxing.pojo.UserRes;
import com.lijiaxing.service.updateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class udpateServiceImpl implements updateService {
    @Autowired
    userMapper um;
    @Autowired
    updateMapper up;

    @Override
    public Result updateUser(UserRes.User user) {
        UserRes.User[] users = um.queryOneUserByUtelAndUid(user.getUtel(), user.getUid());
        System.out.println(user.getUname());
        if (users.length == 0) {
            int i = up.updateUser(user.getUid(), user.getUname(), user.getUtel(), user.getPid());
            if (i == 1) {
                return Result.success("", "修改成功");
            }
            return Result.success("", "修改失败");
        }
        return Result.error("", "手机号已存在");
    }
}
